﻿using System.ComponentModel.DataAnnotations;
using RuTracker.Interface;

namespace RuTracker.MVC.Models.Settings
{
    public class SettingsModel
    {
        public SettingsModel()
        {
            
        }

        public SettingsModel(User user, UserStorageInfo userStorage)
        {
            EMail = user.EMail;
            UserName = user.Name;

            if (userStorage != null)
            {
                DropboxFolderPath = userStorage.StorageFolder;
                HaveToken = userStorage.Token != null;
            }
        }

        [DataType(DataType.Text)]
        [Display(Name = "User Name")]
        public string UserName { get; set; }

        [DataType(DataType.EmailAddress, ErrorMessage = "Invalid email")]
        [Required]
        [Display(Name = "E-mail")]
        public string EMail { get; set; }

        [DataType(DataType.Text, ErrorMessage = "Dropbox folder is required")]
        [Display(Name = "Dropbox folder")]
        public string DropboxFolderPath { get; set; }

        public bool HaveToken { get; private set; }
    }
}